# 引入必要的库
from imageai.Detection import ObjectDetection

# 初始化ObjectDetection类并设置路径
execution_path = os.getcwd()
detector = ObjectDetection()

# 加载预训练的YOLOv4模型
detector.setModelTypeAsYOLOv4()
detector.setModelPath(os.path.join(execution_path, "yolov4.weights"))  # 模型权重文件路径
detector.loadModel()

# 进行人脸检测
image_path = "path_to_your_image.jpg"
outputs = detector.detectObjectsFromImage(input_image=image_path, output_image_path="output.jpg", minimum_percentage_probability=30)

# 处理检测结果
for each_object in outputs:
    print(f"Object: {each_object['name']} - Probability: {each_object['percentage_probability']} - Rectangle: {each_object['box_points']}")